package br.com.cadele.beans;

import java.io.Serializable;
import java.util.ArrayList;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import br.com.cadele.model.Departamento;
import br.com.cadele.service.DepartamentoService;

import com.ocpsoft.pretty.faces.annotation.URLBeanName;
import com.ocpsoft.pretty.faces.annotation.URLMapping;

@ManagedBean(name="visualizarDepartamentoBean")
@ViewScoped
@URLBeanName(value="visualizarDepartamentoBean")
@URLMapping(id="visualizarDepartamentoBean", pattern="/departamento/visualizar", viewId="/pages/departamento/visualizar.xhtml")
public class VisualizarDepartamentoBean implements Serializable{

        private static final long serialVersionUID = -8254042197084584956L;
        Departamento departamento;
        private DepartamentoService departamentoService;
        private ArrayList<Departamento> departamentoList;

        @PostConstruct
        public void init(){
            departamentoService = new DepartamentoService();
            departamentoList = departamentoService.getAll();
        }
        
        public void salvar() {
				departamentoService.executeInsert(departamento);
        }
        
        public ArrayList<Departamento> getDepartamentoList(){
          return departamentoList;
        }
        
        public void setDepartamentoList(ArrayList<Departamento> departamentoList){
          this.departamentoList = departamentoList;
        }
}